#ifndef _Level_h_
#define _Level_h_

#include "BnB_types.h"
#include "SDL.h"

/** @file	Level.h
 *  @author	Julien CLEMENT
 *  @brief	Structure holding the information
 *  		of a level.
 *  		See the file "LevelExample.txt"
 *  		for more information on the format.
 *  		A level consists of a grid of 16x8 bricks
 *  		of size 32x16 pixels.
 */

/* Default values for the level parameters */
#define NO_TIMER		( 0 )

#define DEFAULT_PINSIZE		( 128 )
#define DEFAULT_SPEED		( 3.0 )
#define DEFAULT_EDGESIZE	( 0 )
#define DEFAULT_TIMER		( NO_TIMER )	/* No timer */

/* Min/Max values advised or mandatory for the level parameters */
#define MIN_PINSIZE		( 32 )
#define MAX_PINSIZE		( 128 )
#define MIN_SPEED		( 1.0 )
#define MAX_SPEED		( 10.0 )
#define MIN_EDGESIZE		( 0 )
#define MAX_EDGESIZE		( 320 )
#define MIN_TIMER		( 10 )
#define MAX_TIMER		( 300 )

/* Keywords for the level parameters */
#define KEYWORD_BRICKS		"bricks"
#define KEYWORD_PINSIZE		"pinsize"
#define KEYWORD_SPEED		"speed"
#define KEYWORD_EDGESIZE	"edgesize"
#define KEYWORD_TIMER		"timer"

/* Separator */
#define SEPARATOR		':'
#define COMMENT_TOKEN		'#'

/** @struct Level
 *
 *  @brief  The <i>bricks</i> field stores the bricks. Each
 *  	    is represented by a signed integer whose value
 *  	    represents a particular type of brick.
 *
 */ 
typedef struct
{
	char bricks[16][8];
	short nhits;   /* Count how many hits remain before
			  the level is complete
		       */

	int   pinsize; /* Default pin size */
	float speed;   /* Default ball speed */
	int   edgesize;/* Default edge size */
	Uint32 timer;  /* Number of seconds to complete the level.
			  The special value zéro (0) specifies that
			  there is no timer. */
}Level;

/* Import function.
 * See LevelExample.txt for the expected format.
 */
void Level_import(Level * lvl, const char * filename);

/* Debug function to printout the contents of a Level to stdout.
 * (Mainly used to debug the import function)
 */
void Level_print (Level * lvl);

#endif

